package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class PaymentController {
	
	@Autowired
	private PaymentService paymentService;
	
	@Value("server.port")
	private String serverport;
	
	@GetMapping("/payment/ok")
	public String paymentInfo_ok(){
		String info = paymentService.paymentInfo_OK(3);
		log.info(info);
		return info;
	}
	
	@GetMapping("/payment/timeout")
	public String paymentInfo_timeout(){
		String info = paymentService.paymentInfo_timeout(3);
		log.info(info);
		return info;
	}
	
	public String paymentInfo_timeout_handler(){
		String info = paymentService.paymentInfo_timeout_handler(3);
		log.info(info);
		return info;
	}
	
	//============服务熔断=====================
	@GetMapping("/payment/circuit/{id}")
	public String paymentCircuit(@PathVariable("id")Long id){
		String s = paymentService.payment_circuitBreaker(id);
		log.info(s);
		return s;
	}
}
